From: Florian Müllner Date: Thu, 21 Sep 2023 18:55:31 +0000 (+0200) Subject: status/system: Use Intl to format battery percentage X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~301^2^2~28 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=6f7f0f369b5e6da3f4615e07d69832afeffd0a38;p=gnome-shell.git status/system: Use Intl to format battery percentage The exact way of formatting a percentage value is locale specific: https://en.wikipedia.org/wiki/Percent_sign#Correct_style. We account for that by marking the string for translations, but then get it wrong for the default US locale (go us!). But given that the javascript engine itself provides us with a way of formatting a percentage in a locale-specific way, that seems the better option than putting the burden on our own developers and translators. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7005 Part-of: --- diff --git a/js/ui/status/system.js b/js/ui/status/system.js index 8680b0bdd..ff9fa5624 100644 --- a/js/ui/status/system.js +++ b/js/ui/status/system.js @@ -93,8 +93,9 @@ const PowerToggle = GObject.registerClass({ use_default_fallbacks: false, }); + const formatter = new Intl.NumberFormat(undefined, {style: 'percent'}); this.set({ - title: _('%d\u2009%%').format(this._proxy.Percentage), + title: formatter.format(this._proxy.Percentage / 100), fallback_icon_name: this._proxy.IconName, gicon, });